package design.patterns;

/**
 * 单例模式(饿汉)
 */
public class HungrySingleton {
    //私有化构造方法,不允许外部创建
    private HungrySingleton() {
    }

    //加载类时,直接创建并实例化,只有一份
    private static HungrySingleton instance = new HungrySingleton();

    //提供共有方法,让外部获取
    public static HungrySingleton getInstance() {
        return instance;
    }

}
